<!DOCTYPE html>
<html lang="en">
<head>
    <title>集团意向客户</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1200">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
    <style>
        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
        .table>tbody>tr>th {
            /*border-bottom: 1px solid #cbcbcd;*/
            background: yellow;
            text-align: center;
        }

    </style>
</head>
<body>
<section class="content" id="app">
    <div class="div-td-content-more"><i></i></div>
    <div class="boxItem" style="align-content: center" >
        <div class="box-body no-padding iframeH2" style="overflow: auto;" id="scrollDiv">
            <center>
                <table class="table table-bordered text-center table-width" style="width: 600px;">
                    <tbody>
                    <tr>
                        <th style="width: 25%;">公司</th>
                        <th style="width: 15%;">七天内</th>
                        <th style="width: 15%;">三月内</th>
                        <th style="width: 15%;">三月内</th>
                        <th style="width: 15%;">半年内</th>
                        <th style="width: 15%;">总数</th>
                    </tr>
                    <tr v-for="(item,i) in customerList">
                        <td><span style="color: #2a8cec;" @click="openCompany(item)">{{item.companyName}}</span>
                        </td>
                        <td>{{item.weekNum}}</td>
                        <td>{{item.monthNum}}</td>
                        <td>{{item.threeNum}}</td>
                        <td>{{item.banNianNum}}</td>
                        <td>{{item.allNum}}</td>
                    </tr>
                    <tr>
                        <td>合计</td>
                        <td>{{calculation.week}}</td>
                        <td>{{calculation.month}}</td>
                        <td>{{calculation.threeMonth}}</td>
                        <td>{{calculation.halfYear}}</td>
                        <td>{{calculation.allCount}}</td>
                    </tr>
                    </tbody>
                </table>
            </center>
        </div>
        <div v-if="returnFlag">
            <div style="margin: 0 auto;color: #999999;text-align: center;margin-top: 100px;font-size: 22px;background: #fff;"
                 v-if="!customerList||customerList.length<=0">
                暂无意向客户
            </div>
        </div>
        <div class="clear"></div>
    </div>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=8e743a31"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=54c6b89c"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
    var app = new Vue({
        el: '#app',
        data: {
            userId: getCurrentUser().id,
            companyId:$.wyui.page.urlParams.companyId,
            regionId: '',
            key: '',
            customerList: [],
            calculation: {
                "week": 0,
                "month": 0,
                "threeMonth": 0,
                "halfYear": 0,
                "allCount": 0,
            },
            returnFlag: false,
        },
        methods: {
            get_customerList_group: function () {
                var that = this;
                $.wyui.postMethod("/intentionCustomerManagement/getIntentCustomerReportForGroup.json", {
                    "userId": that.userId,
                }, function (data) {
                    console.log(data.records)
                    that.customerList = data.records
                    //获取合计
                    that.calculation.week = that.getCount(that.customerList, "weekNum");
                    that.calculation.month = that.getCount(that.customerList, "monthNum");
                    that.calculation.threeMonth = that.getCount(that.customerList, "threeNum");
                    that.calculation.halfYear = that.getCount(that.customerList, "banNianNum");
                    that.calculation.allCount = that.getCount(that.customerList, "allNum");
                    that.returnFlag = true;
                });
            },
            //打开公司
            openCompany: function (item, buyDate) {
                var that = this;
                top.closeTabByPageId("openCompany");
                top.addTabs({
                    id: 'openCompany',
                    title: '意向客户列表',
                    close: true,
                    url: '/intentionManagement/intentCustomerPc/managerIntentionalList.html?companyId=' + item.companyId+'&userId=' + that.userId,
                });

            },
            //合并单元格
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },

            //获取合计
            getCount: function (arr, key) {
                var number = 0;
                for (var i = arr.length - 1; i >= 0; i--) {
                    number += (arr[i][key] && arr[i][key] != '-' ? arr[i][key] : 0)

                }
                return number;
            }
        },
        mounted: function () {
            var that = this;
            that.get_customerList_group();
        }
    });

</script>
</body>
</html>